//
//  WLVisitorViewController.swift
//  WLWeibo
//
//  Created by Devil on 16/8/11.
//  Copyright © 2016年 Wiliam. All rights reserved.
//

import UIKit

class WLVisitorViewController: UIViewController {
    
    var isLogin:Bool = WLUserAccountViewModel.sharedTools.isLogin
    
    var visitorView:WLVisitorView?
    
    override func loadView() {
        
        if isLogin{
            
            view = tableView
            
        }else{
            
            setupVisitorView()
        }
        
    }
    func setupVisitorView(){
        
        setupNav()
        visitorView = WLVisitorView()
        visitorView?.closure = {
        
            self.loginAction()
        
        }
        view = visitorView
        
    }
    
    func setupNav(){
      
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        
    }
    
    func loginAction(){
        
        let oauthVc = WLOAuthViewController()
        
        presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    lazy var tableView: UITableView = UITableView()
    
}
